import { RouteRecordRaw } from 'vue-router';
import ExampleView from '@/views/ExampleView.vue';
import AdminView from '@/views/AdminView.vue';
import NoAuthView from '@/views/NoAuthView.vue';
import ACCESS_ENUM from '@/access/accessEnum';
import UserLayout from '@/layouts/UserLayout.vue';
import UserLoginView from '@/views/user/UserLoginView.vue';
import UserRegisterView from '@/views/user/UserRegisterView.vue';
import AddQuestionView from '@/views/question/AddQuestionView.vue';
import ManageQuestionView from '@/views/question/ManageQuestionView.vue';
import QuestionsView from '@/views/question/QuestionsView.vue';
import ViewQuestionView from '@/views/question/ViewQuestionView.vue';

export const routes: Array<RouteRecordRaw> = [
  {
    path: '/user',
    name: '用户',
    component: UserLayout,
    meta: {
      hideInMenu: true
    },
    children: [
      {
        path: '/user/login',
        name: '登录',
        component: UserLoginView
      },
      {
        path: '/user/register',
        name: '注册',
        component: UserRegisterView
      }
    ]
  },
  {
    path: '/question',
    name: '浏览题目',
    component: QuestionsView
  },
  {
    path: '/view/question/:id',
    name: '在线做题',
    component: ViewQuestionView,
    props: true,
    meta: {
      access: ACCESS_ENUM.USER,
      hideInMenu: true
    }
  },
  {
    path: '/add/question',
    name: '新增题目',
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.USER
    }
  },
  {
    path: '/update/question',
    name: '更新题目',
    component: AddQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN,
      hideInMenu: true
    }
  },
  {
    path: '/manage/question',
    name: '管理题目',
    component: ManageQuestionView,
    meta: {
      access: ACCESS_ENUM.ADMIN
    }
  },
  {
    path: '/',
    name: '主页',
    component: ExampleView
  },

  {
    path: '/noAuth',
    name: '无权限',
    component: NoAuthView,
    meta: {
      hideInMenu: true
    }
  },
  {
    path: '/hide',
    name: '隐藏页面',
    component: ExampleView,
    meta: {
      hideInMenu: true
    }
  }
];
